/**
 * 成功响应构造器
 * @param {any} data 返回数据
 * @param {string} message 成功消息
 * @returns {Object} 响应对象
 */
export const successResponse = (data, message = '操作成功') => ({
    code: 200,
    success: true,
    message,
    data
})

/**
 * 错误响应构造器
 * @param {string} message 错误消息
 * @param {number} code 错误码
 * @returns {Object} 响应对象
 */
export const errorResponse = (message, code = 500) => ({
    code,
    success: false,
    message
})

/**
 * 模拟网络延迟
 * @param {number} delay 延迟时间(ms)
 * @returns {Promise} 延迟Promise
 */
export const mockDelay = (delay = 300) =>
    new Promise(resolve => setTimeout(resolve, delay))